﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WorkTitleAndTeacher.aspx.cs"
    Inherits="Basic4Net.OAWeb.Module_Base.WorkTitleAndTeacher" %>

<%@ Register Assembly="Controls" Namespace="Basic4Net.Controls" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../App_Themes/ui-lightness/main.css" rel="stylesheet" type="text/css" />

</head>
<body onload="myload();">
    <div class="mainWarp">
        <div class="pageBody">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <div  style=" margin-top:8px; margin-left:1px;">
        <input type="button" id="btnSetPosition" value="设置选中分类" onclick="OpenPositionSetting();" class="commonBut"/>

        <label>职称:</label>
        <asp:DropDownList ID="drPosition" runat="server" OnSelectedIndexChanged="DrPositionChanged" AutoPostBack="True">
        </asp:DropDownList>

        <label>工号或姓名:</label>
        <asp:TextBox ID="txtCode" runat="server"></asp:TextBox>
        <asp:Button ID="btnSearch" runat="server" Text="搜索" OnClick="BtnSearchClick" CssClass="commonBut"/>
    </div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Repeater ID="Repeater1" runat="server">
                <HeaderTemplate>
                    <table id="teacherTable" border="0" cellpadding="0" cellspacing="1" class="useList1" style=" width:680px;">
                        <tr class="tableTitle">
                            <th style="text-align:center; width:80px;">
                                <input id="chkSelectAll" type="checkbox" onclick="SelectAll(this);"/>全选
                            </th>
                            <th style="text-align:center; width:200px;">
                                职称
                            </th>
                            <th  style="text-align:center; width:80px;">
                                工号
                            </th>
                            <th  style="text-align:center; width:120px;">
                                姓名
                            </th>
                            <th  style="text-align:center; width:200px;">
                                职务
                            </th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <input type="checkbox" id="chk_<%#Eval("TeacherId") %>" value="<%#Eval("TeacherId") %>" />
                        </td>
                        <td style=" text-align:left; padding-left:5px;">
                            <%#Eval("PositionName")%>
                        </td>
                        <td style=" text-align:left; padding-left:5px;">
                            <%#Eval("TeacherCode")%>
                        </td>
                        <td style=" text-align:left; padding-left:5px;">
                            <%#Eval("TeacherName")%>
                        </td>
                        <td style=" text-align:left; padding-left:5px;">
                            <%#Eval("PostName")%>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
            <div style=" text-align:left; padding-top:8px;">
            <webdiyer:BNPager ID="aspNetPager" runat="server" PageSize="20" Width=680
                 OnPageChanged="AspNetPagerPageChanged">
            </webdiyer:BNPager>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="aspNetPager" EventName="PageChanged" />
            <asp:AsyncPostBackTrigger ControlID="drPosition" EventName="SelectedIndexChanged" />
        </Triggers>
    </asp:UpdatePanel>

    <!-- 弹出界面 开始-->
    <div id="popTable" class="layoutWarp" style="display: none; width: 280px; overflow: inherit;">
        <div class="title">
            <span id="formTitle">职称设置</span> <a title="关闭" onclick="ClosePopForm('popTable', true);">
                关闭</a>
        </div>
        <table id="PTableInfo" style="width: 95%; margin-top: 12px;" border="0" class="layoutTable">
            <tr>
                <td>
                    <label>
                        分类名称:</label>
                </td>
                <td>
                    <asp:DropDownList ID="drPositionInPop" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td colspan="6" align="center">
                    <ul class="butList">
                        <input type="hidden" id="hidTeacherIDs" value="" />
                        <input type="button" id="btnsave" value="设置" onclick="UpdatePosition()" class="commonBut" />
                        <input type="button" value="取消" onclick="ClosePopForm('popTable', true);" class="commonBut" />
                    </ul>
                </td>
            </tr>
        </table>
    </div>
    </form>
    </div></div>
</body>

<script type="text/javascript" src="../Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="../Scripts/common.js"></script>
<script type="text/javascript" src="../Scripts/Util.js"></script>
<script type="text/javascript">
    function myload() {
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(EndRequestHandler);
    }
    function EndRequestHandler() {
        $("input[type='submit']").addClass("commonBut");
    }

    $(document).ready(function () {
        $("input[type='button']").addClass(function () {
            return "commonBut";
        });
    });

    var arr = [];
    // 打开弹出层
    function OpenPositionSetting() {
        arr = [];
        $("input[type='checkbox'][id!='chkSelectAll'][checked]").val(
        function () {
            arr.push(Number(this.value));
        }
        );

        if (arr.length < 1) {
            showMassgeBox("提示", "没有选中任何教师.", 1);
            return;
        }
        ShowPopForm("popTable", "formTitle", "职称设置", "");
    }

    // 全选
    function SelectAll(obj) {
        if (obj.checked)
            $("input[type='checkbox'][id!='chkSelectAll']").attr("checked", true);
        else
            $("input[type='checkbox'][id!='chkSelectAll']").removeAttr("checked");
    }

    // 更新职务设置
    function UpdatePosition() {
        debugger;
        PageMethods.UpdatePosition(arr, $("#<%=drPositionInPop.ClientID %>").val(),
            function (succ) {
                if (succ == null || succ.length < 1)
                    showMassgeBox("提示", "设置成功!", 1);
                else
                    showMassgeBox("提示", succ, 1);
                document.getElementById("<%=btnSearch.ClientID %>").click();
                ClosePopForm('popTable', true);
            },
            function (err) {
                if (err == null || err.length < 1)
                    showMassgeBox("提示", "设置失败", 1);
                else
                    showMassgeBox("提示", err, 1);
                document.getElementById("<%=btnSearch.ClientID %>").click();
            }
        );
    }
</script>
</html>
